package com.superman.view;

import com.alibaba.fastjson.JSON;
import com.superman.entity.Record_User_Car;
import com.superman.socket.TCPClient;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class RentAndReturn {

    public List<Record_User_Car> rentCar(String user_id, String car_number){
        List<Record_User_Car> list = new ArrayList<>();
        try {
            list = JSON.parseArray(TCPClient.getResponse("rentCar#" + user_id + "#" + car_number), Record_User_Car.class);
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            return list;
        }
    }

    public List<Record_User_Car> returnCar(String car_id){
        List<Record_User_Car> list = new ArrayList<>();
        try {
            list = JSON.parseArray(TCPClient.getResponse("returnCar#" + car_id), Record_User_Car.class);
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            return list;
        }
    }
}
